﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using DunLibrary.User;
using System.Collections.Generic;
using System.Linq;

namespace DunSilverlight.Comm
{
    /// <summary>
    /// 客户端权限管理
    /// </summary>
    public static class RightManagement
    {
        /// <summary>
        /// 定义所有权限代码的常量
        /// </summary>
        /// 
        public const string Right_Import_Arrear = "import_ArrearData";//欠款数据导入权限

        public const string Right_Import_Return = "import_returnData";//回款数据导入权限

        public const string Right_Allot_Frist_Case = "allot_frist_case";//催收任务初步分配

        public const string Right_Allot_Case = "allot_case";//催收任务分配

        public const string Right_Process_Case = "process_case";//催收处理

        public const string Right_Visits_Check = "visits_check";//外访审核

        public const string Right_Investigate_Check = "investigate_check";//第三方调查审核

        public const string Right_Finish_Case = "finish_case";//结案处理

        public const string Right_Organization_Manage = "org_manage";//组织机构管理

        public const string Right_Right_Manage = "right_manage";//权限管理

        public const string Right_Right_Add = "right_add";//权限分配

        public const string Right_Base_Manage = "base_manage";//基础资料管理

        public const string Right_View_All_Case="view_all_case"; //所有催款记录查询权

        public const string Right_Comment = "comment";//批注权限

        public const string Right_Admin = "admin";//系统管理员权限


        public const string Right_Report_PhoneCallQuery = "report_PhoneCallQuery";//催收情况查询

        public const string Right_Report_PhoneCallStatistic = "report_PhoneCallStatistic";//催收工作量统计

        public const string Right_Report_CaseReturnStatistic = "report_CaseReturnStatistic";//回款率统计

        public const string Right_Report_Word = "report_work";//word文档生成

        public const string Right_Report_Excel = "report_excel";//excel文档生成

        /// <summary>
        /// 验证当前用户权限
        /// </summary>
        /// <param name="right"></param>
        /// <returns></returns>
        public static bool VerifyRight(string right)
        {
            IList<Right> rights = AppGlobal.CurrentRights;
            if (rights == null)
            {
                return false;
            }

            if (rights.FirstOrDefault(p => p.Number == Right_Admin) != null)
            {
                return true;//如果是系统管理员，则拥有所有权限!
            }
            else if (rights.FirstOrDefault(p => p.Number == right) != null)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    }
}
